/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */

package org.openmrs.module.datalogging.service.impl;

import org.openmrs.BaseOpenmrsObject;
import org.openmrs.Encounter;
import org.openmrs.Obs;
import org.openmrs.Person;
import org.openmrs.module.datalogging.configuration.Event;
import org.openmrs.module.datalogging.configuration.Variable;
import org.openmrs.module.datalogging.db.DataLoggingDAO;
import org.openmrs.module.datalogging.enums.EventType;
import org.openmrs.module.datalogging.model.LogEvent;
import org.openmrs.module.datalogging.service.DataLoggingService;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class DataLoggingServiceImpl implements DataLoggingService {
	
	private DataLoggingDAO dataLoggingDAO;
	
	/**
	 * @param dataLoggingDAO the summaryDAO to set
	 */
	public void setDataLoggingDAO(DataLoggingDAO dataLoggingDAO) {
		this.dataLoggingDAO = dataLoggingDAO;
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#saveLogEvent(org.openmrs.module.datalogging.model.LogEvent)
	 */
	@Override
	public LogEvent saveLogEvent(LogEvent logEvent) {
		return dataLoggingDAO.saveLogEvent(logEvent);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getEvent(java.lang.Integer)
	 */
	@Override
	public LogEvent getLogEvent(Integer eventId) {
		return dataLoggingDAO.getLogEvent(eventId);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getPersonEvents(org.openmrs.Person)
	 */
	@Override
	public List<LogEvent> getPersonEvents(Person person) {
		return dataLoggingDAO.getLogEvents(person);
	}

	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getAllEvents()
	 */
	@Override
	public List<LogEvent> getLogEvents() {
		return dataLoggingDAO.getLogEvents();
	}

	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#saveEvent(org.openmrs.module.datalogging.configuration.Event)
	 */
	@Override
	public Event saveEvent(Event event) {
		return dataLoggingDAO.saveEvent(event);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getEvent(java.lang.Integer)
	 */
	@Override
	public Event getEvent(Integer eventId) {
		return dataLoggingDAO.getEvent(eventId);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getEventsByEvent(org.openmrs.module.datalogging.enums.EventType)
	 */
	@Override
	public List<Event> getEventsByEvent(EventType triggeringEvent) {
		return dataLoggingDAO.getEventsByEvent(triggeringEvent);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getAllEvents()
	 */
	@Override
	public List<Event> getAllEvents() {
		return dataLoggingDAO.getAllEvents();
	}
	
	@Override
	public List<Event> findEvents(String partialName) {
		return dataLoggingDAO.findEvents(partialName);
	}
	
	@Override
	public Event getEvent(String name) {
		return dataLoggingDAO.getEvent(name);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#saveComponent(org.openmrs.module.datalogging.configuration.Variable)
	 */
	@Override
	public Variable saveComponent(Variable variable) {
		return dataLoggingDAO.saveComponent(variable);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getComponent(java.lang.Integer)
	 */
	@Override
	public Variable getComponent(Integer variableId) {
		return dataLoggingDAO.getComponent(variableId);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getAllComponents()
	 */
	@Override
	public List<Variable> getAllComponents() {
		return dataLoggingDAO.getAllComponents();
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#findComponents(java.lang.String)
	 */
	@Override
	public List<Variable> findComponents(String partialName) {
		return dataLoggingDAO.findComponents(partialName);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#getComponent(java.lang.String)
	 */
	@Override
	public Variable getComponent(String name) {
		return dataLoggingDAO.getComponent(name);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#findEncounters(org.openmrs.Person, java.util.Map)
	 */
	@Override
	public List<Encounter> findEncounters(Person person, Map<String, Set<BaseOpenmrsObject>> map) {
		return dataLoggingDAO.findEncounters(person, map);
	}
	
	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#findEncounters(org.openmrs.Person, java.util.Map)
	 */
	@Override
	public List<Obs> findObservations(Person person, Map<String, Set<BaseOpenmrsObject>> map) {
		return dataLoggingDAO.findObservations(person, map);
	}

	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#countEvents(java.lang.String)
	 */
	@Override
    public Integer countEvents(String search) {
	    return dataLoggingDAO.countEvents(search);
    }

	/**
	 * @see org.openmrs.module.datalogging.service.DataLoggingService#findEvents(java.lang.String, int, int)
	 */
	@Override
    public List<LogEvent> findEvents(String search, int start, int length) {
	    return dataLoggingDAO.findEvents(search, start, length);
    }
}
